from fastapi import APIRouter, Depends
from loguru import logger

from app.api.models import AdmissionReviewResponse
from app.api.webhook import AdmissionWebhook

api_router = APIRouter(tags=["main"])


@api_router.get("/health")
async def health_check():
    logger.info("Health check")
    return {"code": 200, "message": "ok", "data": None}


@api_router.post(
    path="/validate",
    response_model=AdmissionReviewResponse,
    response_model_exclude_unset=True,
    response_model_exclude_none=True,
)
async def validate(wh: AdmissionWebhook = Depends()):
    return wh.validate()


@api_router.post(
    path="/mutate",
    response_model=AdmissionReviewResponse,
    response_model_exclude_unset=True,
    response_model_exclude_none=True,
)
async def mutate(wh: AdmissionWebhook = Depends()):
    return wh.mutate()
